﻿using System.Windows;
using System.Windows.Controls;

namespace PeoplesJukebox.Web.UserControls
{
    /// <summary>
    /// Generic keypad control for entering characters
    /// </summary>
    public partial class KeyPad : UserControl
    {
        public delegate void KeypadClearedEventHandler();
        public event KeypadClearedEventHandler KeypadCleared;

        /// <summary>
        /// Gets/sets the textbox to write to
        /// </summary>
        public TextBox TextBox {get; set;}

        /// <summary>
        /// Default constructor
        /// </summary>
        public KeyPad()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.TextBox.Text = string.Concat(this.TextBox.Text, ((Button)sender).Content);
        }

        private void ResetButtonClick(object sender, RoutedEventArgs e)
        {
            this.TextBox.Text = string.Empty;
            if (KeypadCleared != null)
            {
                KeypadCleared();
            }
        }
    }
}